// TypeScript file
module view {
    export class GameViewPlay extends eui.Component {

        private backhomeskin: view.GameViewBackHomePanel
        private ruleskin: view.GameViewGameRulePanel
        private soundskin: view.GameViewGameSoundPanel
        private tishiskin: view.GameViewGameTiShiPanel

        private btnnote: eui.Button;
        private btnrule: eui.Button;
        private btnhome: eui.Button;
        private btnmessage: eui.Button;
        private btnsound: eui.Button;
        private btnready: eui.Button;
        private btnqiangzhuang: eui.Button;
        private btnbuqiang: eui.Button;
        private btntanpai: eui.Button;
        private btntishi: eui.Button;
        private btnone: eui.Button;
        private btntwo: eui.Button;
        private btnthree: eui.Button;
        private btnfour: eui.Button;
        private btnfive: eui.Button;

        private bgimg: eui.Image
        private textready1: eui.Image; private textready2: eui.Image; private textready3: eui.Image; private textready4: eui.Image; private textready5: eui.Image; private textready6: eui.Image;
        private qiangzhuang1: eui.Image; private qiangzhuang2: eui.Image; private qiangzhuang3: eui.Image; private qiangzhuang4: eui.Image; private qiangzhuang5: eui.Image; private qiangzhuang6: eui.Image;
        private touxiang1: eui.Image; private touxiang11: eui.Image;
        private touxiang2: eui.Image; private touxiang22: eui.Image;
        private touxiang3: eui.Image; private touxiang33: eui.Image;
        private touxiang4: eui.Image; private touxiang44: eui.Image;
        private touxiang5: eui.Image; private touxiang55: eui.Image;
        private touxiang6: eui.Image; private touxiang66: eui.Image;
        private zhushu1: eui.Image; private zhushu2: eui.Image; private zhushu3: eui.Image; private zhushu4: eui.Image; private zhushu5: eui.Image; private zhushu6: eui.Image;
        private zhuang1: eui.Image; private zhuang2: eui.Image; private zhuang3: eui.Image; private zhuang4: eui.Image; private zhuang5: eui.Image; private zhuang6: eui.Image;
        private puke11: eui.Image;
        private puke12: eui.Image;
        private puke13: eui.Image;
        private puke14: eui.Image;
        private puke21: eui.Image;
        private puke22: eui.Image;
        private puke23: eui.Image;
        private puke24: eui.Image;
        private puke31: eui.Image;
        private puke32: eui.Image;
        private puke33: eui.Image;
        private puke34: eui.Image;
        private puke41: eui.Image;
        private puke42: eui.Image;
        private puke43: eui.Image;
        private puke44: eui.Image;
        private puke51: eui.Image;
        private puke52: eui.Image;
        private puke53: eui.Image;
        private puke54: eui.Image;
        private puke61: eui.Image;
        private puke62: eui.Image;
        private puke63: eui.Image;
        private puke64: eui.Image;
        private paixing11: eui.Image; private paixing12: eui.Image; private paixing21: eui.Image; private paixing22: eui.Image; private paixing31: eui.Image; private paixing32: eui.Image;
        private paixing41: eui.Image; private paixing42: eui.Image; private paixing51: eui.Image; private paixing52: eui.Image; private paixing61: eui.Image; private paixing62: eui.Image;

        private timergroup: eui.Group;
        private xiazhu: eui.Group
        private sendmessage: eui.Group
        private usermessagegroup1: eui.Group; private usermessagegroup2: eui.Group; private usermessagegroup3: eui.Group; private usermessagegroup4: eui.Group; private usermessagegroup5: eui.Group; private usermessagegroup6: eui.Group
        private user1: eui.Group; private user2: eui.Group; private user3: eui.Group; private user4: eui.Group; private user5: eui.Group; private user6: eui.Group;

        private nicheng1: eui.Label; private nicheng2: eui.Label; private nicheng3: eui.Label; private nicheng4: eui.Label; private nicheng5: eui.Label; private nicheng6: eui.Label;
        private jushu: eui.Label
        private difen: eui.Label
        private fangkashu: eui.Label
        private timenumber: eui.Label
        private timenode: eui.Label
        private tishi: eui.Label
        private message1: eui.Label; private message2: eui.Label; private message3: eui.Label; private message4: eui.Label; private message5: eui.Label
        private message6: eui.Label; private message7: eui.Label; private message8: eui.Label; private message9: eui.Label; private message10: eui.Label; private message11: eui.Label
        private usermessage1: eui.Label; private usermessage2: eui.Label; private usermessage3: eui.Label; private usermessage4: eui.Label; private usermessage5: eui.Label; private usermessage6: eui.Label
        private jinbi1: eui.Label; private jinbi2: eui.Label; private jinbi3: eui.Label; private jinbi4: eui.Label; private jinbi5: eui.Label; private jinbi6: eui.Label
        private jiesuanjinbi1: eui.Label; private jiesuanjinbi2: eui.Label; private jiesuanjinbi3: eui.Label; private jiesuanjinbi4: eui.Label; private jiesuanjinbi5: eui.Label; private jiesuanjinbi6: eui.Label;
        private user: string[][]
        private soket: tool.GameWebSocket
        private linkbtn: eui.Button;

        public static CreateRoom: string = "CreateRoom";
        public static PrepareJoinRoom: string = "PrepareJoinRoom";
        public static JoinRoom: string = "JoinRoom";
        public static PullRoomInfo: string = "PullRoomInfo";
        public static AllGamerInfo: string = "AllGamerInfo";
        public static UpdateGamerInfo: string = "UpdateGamerInfo";
        public static UpdateAccountStatus: string = "UpdateAccountStatus";
        public static UpdateAccountShow: string = "UpdateAccountShow"
        public static UpdateAccountMultiples: string = "UpdateAccountMultiples"
        public static StartShow: string = "StartShow"
        public static GameStart: string = "GameStart"
        public static MyCards: string = "MyCards"
        public static StartLimitTime: string = "StartLimitTime"
        public static StartBet: string = "StartBet"
        public static StartKickCard: string = "StartKickCard"
        public static Win: string = "Win"
        public static ReadyStart: string = "ReadyStart";
        public static GrabBanker: string = "GrabBanker";
        public static PlayerMultiples: string = "PlayerMultiples";
        public static ShowCard: string = "ShowCard";
        public static Controller: string = "Controller";
        public static BroadcastVoice: string = "BroadcastVoice";

        public static ALERT_TIPS: string = "alert_tips";
        public static JOIN_TIPS: string = "joinroom";
        public static globalData = {};
        public static user_accound = [];
        public static game_userid = [];
        public pai = [];
        private randcords: any[] = [];
        private score_board = [];
        public showcards = {};
        public timertest: egret.Timer;
        public user_in_game = [];

        public constructor() {
            super();
            this.skinName = view.GameViewRoomSkin;
            this.bgimg.addEventListener(egret.TouchEvent.TOUCH_TAP, function () { this.sendmessage.visible = false }, this)//点击桌面隐藏对话框
            SoundMenager.Shared();//加载背景音乐

            var dataURL = SoundMenager.urlSearch()
            if (dataURL["room_id"] && dataURL["member_id"] && dataURL["userid"]) {//加入房间
                RES.getResByUrl(tool.HttpService.getHTTP_Connect(dataURL["room_id"], dataURL["member_id"], dataURL["userid"]), this.httpFirst, this, RES.ResourceItem.TYPE_JSON);
                // RES.getResByUrl(tool.HttpService.getWxConfig(dataURL["room_id"], dataURL["member_id"], dataURL["userid"]), this.onWxConfigHandler, this, RES.ResourceItem.TYPE_JSON);
            } else if (dataURL["room_id"]) {//加入房间
                RES.getResByUrl(tool.HttpService.getHTTP_Connect(dataURL["room_id"], dataURL["userid"]), this.httpFirst, this, RES.ResourceItem.TYPE_JSON);
                // RES.getResByUrl(tool.HttpService.getWxConfig(dataURL["room_id"]), this.onWxConfigHandler, this, RES.ResourceItem.TYPE_JSON);
            } else {//创建房间
                this.soket = tool.GameWebSocket.getSocket();
                this.soket.socketService.addEventListener(tool.WebSocketService.SOCKET_DATA, this.soketFun, this);//监听soket通信，如果收到数据则运行soketFun
                this.soket.socketService.addEventListener(tool.WebSocketService.SOCKET_CONNECT, this.connectHandler, this);//监听soket通信，如果通信成功则运行connectHandler
            }
            window["soketFun"] = this.soketFun;
            window["that"] = this;

        }
        private wxConfig: any;
        private onWxConfigHandler(data: any): void {
            this.wxConfig = data;
            var obj: BodyConfig = new BodyConfig();
            obj.appId = data.appId;
            obj.debug = data.debug;
            obj.nonceStr = data.nonceStr;
            obj.signature = data.signature;
            obj.timestamp = data.timestamp;
            obj.jsApiList = data.jsApiList;
            wx.config(obj);
            var that = this;
            wx.ready(function () {
                var str = location.href; //取得整个地址栏
                var num = str.indexOf("?")
                var href: string;
                if (num != -1) {
                    href = str.substring(0, num);
                } else {
                    href = str;
                }
                var bodyMenuShareTimeline: BodyMenuShareTimeline = new BodyMenuShareTimeline();
                bodyMenuShareTimeline.title = window.localStorage.getItem("room_number") + "号三公比金花房间";
                bodyMenuShareTimeline.link = href + "?room_id=" + window.localStorage.getItem("room_number");
                bodyMenuShareTimeline.imgUrl = href + "resource/image/home/sangong.png";
                bodyMenuShareTimeline.success = function () {
                    console.error("分享到朋友圈")
                }
                bodyMenuShareTimeline.cancel = function () {
                    console.error("取消分享到朋友圈")
                }
                bodyMenuShareTimeline.fail = function (res) {
                    console.error(res, "====>>>>>=====")
                }
                /* 分享到朋友圈”按钮点击状态及自定义分享内容接口 */
                wx.onMenuShareTimeline(bodyMenuShareTimeline)
                var bodyMenuShareAppMessage: BodyMenuShareAppMessage = new BodyMenuShareAppMessage()
                bodyMenuShareAppMessage.title = window.localStorage.getItem("room_number") + "号三公比金花房间";
                bodyMenuShareAppMessage.desc = "一款好玩游戏大家一起来玩吧"
                bodyMenuShareAppMessage.link = href + "?room_id=" + window.localStorage.getItem("room_number");
                bodyMenuShareAppMessage.imgUrl = href + "resource/image/home/sangong.png";
                bodyMenuShareAppMessage.dataUrl = href + "?room_id=" + window.localStorage.getItem("room_number");
                bodyMenuShareAppMessage.type = "1";
                /**
                * 获取“分享给朋友”按钮点击状态及自定义分享内容接口
                * @param bodyMenuShareAppMessage
                */
                wx.onMenuShareAppMessage(bodyMenuShareAppMessage);
            })
            wx.error(function (res) {
                console.error(res);
            })
            console.error(data)

        }
        private httpFirst(data): void {//加入房间时刚进本界面就通过HTTP链接，链接成功收到房间信息保存在GameViewPlay.globalData
            if (data && data["result"] == 0) {
                GameViewPlay.globalData = data;//HTTP链接成功后返回的数据保存起来
                console.log(data, "========HTTP========");
                window.localStorage.setItem("score_type", data["data"]["room"]["score_type"]);
                window.localStorage.setItem("rule_type", data["data"]["room"]["rule_type"]);
                window.localStorage.setItem("banker_mode", data["data"]["room"]["banker_mode"]);
                window.localStorage.setItem("account_id", data["data"]["memberinfo"]["id"]);
                window.localStorage.setItem("ticket_type", data["data"]["room"]["ticket_type"]);
                window.localStorage.setItem("cards", data["data"]["memberinfo"]["cards"]);
                window.localStorage.setItem("room_number", data["data"]["room"]["room_number"]);
                window.localStorage.setItem("room_id", data["data"]["room"]["id"]);
            } else {
                this.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, { "result_message": "房间地址或账户ID\n\n有误，请确认后重\n\n新登录！" });
            }
            // var dataURL = SoundMenager.urlSearch()
            // if (dataURL["room_id"] && dataURL["member_id"] && dataURL["userid"]) {//加入房间
            //     RES.getResByUrl(tool.HttpService.getWxConfig(dataURL["room_id"], dataURL["member_id"], dataURL["userid"]), this.onWxConfigHandler, this, RES.ResourceItem.TYPE_JSON);
            // } else if (dataURL["room_id"]) {//加入房间
            //     RES.getResByUrl(tool.HttpService.getWxConfig(dataURL["room_id"]), this.onWxConfigHandler, this, RES.ResourceItem.TYPE_JSON);
            // }
            this.soket = tool.GameWebSocket.getSocket();
            this.soket.socketService.addEventListener(tool.WebSocketService.SOCKET_DATA, this.soketFun, this);//监听soket通信，如果收到数据则运行soketFun
            this.soket.socketService.addEventListener(tool.WebSocketService.SOCKET_CONNECT, this.connectHandler, this);//监听soket通信，如果通信成功则运行connectHandler
        }
        public setData(data): void {
            this.jump_jiesuan();
            RES.loadGroup("play");//加载游戏桌面的图片
            this.jushu.text = data["data"]["game_num"] + 1 + "/" + data["data"]["total_num"] + "局"
            this.difen.text = "底分：" + data["data"]['base_score'] + "分";//低分
            this.fangkashu.text = window.localStorage.getItem("cards") + "张"//房卡数
        }
        private soketFun(e: egret.Event) {//根据soket接收的数据判断用户和房间的状态
            var obj = e.data;
            if (obj) {
                var that = this;
                this.pai = ["A1", "B1", "C1", "D1", "A2", "B2", "C2", "D2", "A3", "B3", "C3", "D3", "A4", "B4", "C4", "D4", "A5", "B5", "C5", "D5", "A6", "B6", "C6", "D6", "A7", "B7", "C7", "D7", "A8", "B8", "C8", "D8", "A9", "B9", "C9", "D9", "A10", "B10", "C10", "D10", "A11", "B11", "C11", "D11", "A12", "B12", "C12", "D12", "A13", "B13", "C13", "D13", "E1", "E2"];
                switch (obj.operation) {
                    case GameViewPlay.CreateRoom: {//创建房间
                        if (e.data["result"] != 0) {//创建房间失败并返回错误信息[e.data.result_message]
                            that.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, e.data);
                        } else {
                            window.localStorage.setItem("room_id", e.data["data"]["room_id"]);
                            window.localStorage.setItem("room_number", e.data["data"]["room_number"]);
                            this.soket.sendMessage(tool.SendData.sendJoinRoomData());
                            this.dispatchEventWith(GameViewPlay.CreateRoom, true, e.data["data"]);
                        }
                    } break;
                    case GameViewPlay.PrepareJoinRoom: {//准备进入房间，获得是否加入游戏的提示框信息
                        if (e.data["result"] != 0) {//加入房间失败并返回错误信息[e.data.result_message]
                            that.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, e.data);
                        } else {//询问是否加入房间
                            this.dispatchEventWith(GameViewPlay.JOIN_TIPS, true, e.data["data"]);
                        }
                    } break;
                    case GameViewPlay.JoinRoom: {//加入房间
                        if (e.data["result"] != 0) {//加入房间失败并返回错误信息[e.data.result_message]
                            that.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, e.data)
                        } else {
                            if (e.data['data']['game_num'] == e.data['data']['total_num']) {//本局数等于所有局数时房间关闭去斗牛榜
                                window.localStorage.removeItem("score_type")
                                window.localStorage.removeItem("rule_type");
                                window.localStorage.removeItem("banker_mode");
                                window.localStorage.removeItem("account_id");
                                window.localStorage.removeItem("ticket_type");
                                window.localStorage.removeItem("cards");
                                window.localStorage.removeItem("room_number");
                                window.localStorage.removeItem("room_id");
                                this.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, { "result_message": "房间局数已完" });
                            } else {
                                RES.loadGroup("cards");//加载牌的图片
                                SoundMenager.Shared().PlayBGM();//开始播放背景音乐
                                that.dispatchEventWith(GameViewPlay.JoinRoom, true, e.data);
                            }
                        }
                    } break;
                    case GameViewPlay.AllGamerInfo: {//拉取全部用户的信息，将本用户ID保留GameViewPlay.user_accound，更新各玩家的头像、昵称、金币数
                        if (e.data["result"] != 0) {
                            that.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, e.data)
                        } else {//成功获取玩家信息,更新玩家的头像、昵称、金币数
                            var user = 0;
                            for (var i = 0; i < e.data["data"].length; i++) {
                                var item = e.data["data"][i];
                                if (item["account_status"] > 2) { GameViewPlay.game_userid[user] = item["account_id"]; user++; }
                                GameViewPlay.user_accound[i] = item["account_id"];
                            }
                            this.btnready.visible = true;
                            console.log(GameViewPlay.user_accound);
                            var k: number;
                            var m: number;
                            var j = 0;
                            k = PuKeMenager.four(GameViewPlay.user_accound, window.localStorage.getItem("account_id"));//k为本人所在的位置
                            for (var i = 0; i < e.data["data"].length; i++) {
                                m = PuKeMenager.four(GameViewPlay.user_accound, e.data["data"][i]["account_id"]);//m为这个玩家所在的位置
                                if (m < k) { jueduizhi = GameViewPlay.user_accound.length - k + m; } else { jueduizhi = m - k }
                                var nich;
                                if (e.data["data"][i]["nickname"].length > 4) {
                                    nich = e.data["data"][i]["nickname"].substr(0, 4);
                                } else {
                                    nich = e.data["data"][i]["nickname"];
                                }
                                if (jueduizhi + 1 == 1) { this.user1.visible = true; this.touxiang1.source = tool.SendData.strReplace(e.data["data"][i]["headimgurl"]); this.nicheng1.text = nich; this.jinbi1.text = e.data["data"][i]["account_score"]; }
                                if (jueduizhi + 1 == 2) { this.user2.visible = true; this.touxiang2.source = tool.SendData.strReplace(e.data["data"][i]["headimgurl"]); this.nicheng2.text = nich; this.jinbi2.text = e.data["data"][i]["account_score"]; }
                                if (jueduizhi + 1 == 3) { this.user3.visible = true; this.touxiang3.source = tool.SendData.strReplace(e.data["data"][i]["headimgurl"]); this.nicheng3.text = nich; this.jinbi3.text = e.data["data"][i]["account_score"]; }
                                if (jueduizhi + 1 == 4) { this.user4.visible = true; this.touxiang4.source = tool.SendData.strReplace(e.data["data"][i]["headimgurl"]); this.nicheng4.text = nich; this.jinbi4.text = e.data["data"][i]["account_score"]; }
                                if (jueduizhi + 1 == 5) { this.user5.visible = true; this.touxiang5.source = tool.SendData.strReplace(e.data["data"][i]["headimgurl"]); this.nicheng5.text = nich; this.jinbi5.text = e.data["data"][i]["account_score"]; }
                                if (jueduizhi + 1 == 6) { this.user6.visible = true; this.touxiang6.source = tool.SendData.strReplace(e.data["data"][i]["headimgurl"]); this.nicheng6.text = nich; this.jinbi6.text = e.data["data"][i]["account_score"]; }
                                if (m < k) {
                                    this.A_status(e.data["data"][i]["account_status"], e.data["data"][i], GameViewPlay.user_accound.length + m, k);
                                } else {
                                    this.A_status(e.data["data"][i]["account_status"], e.data["data"][i], m, k);
                                }
                                if (e.data["data"][i]["account_status"] > 2) {
                                    this.user_in_game[j] = e.data["data"][i]["account_id"]; j++
                                }
                            }
                        }
                    } break;
                    case GameViewPlay.UpdateGamerInfo: {//某玩家状态状态改变就重新获取所有玩家信息
                        if (e.data["result"] == 0) {
                            if (e.data["data"] != null) {//新玩家进房
                                this.soket.sendMessage(tool.SendData.sendPullRoomInfoData());
                            }
                        } else {
                            this.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, { "result_message": "内部错误，请刷新后重试！" });
                        }
                    } break;
                    case GameViewPlay.UpdateAccountStatus: {//用户状态改变,更新该用户的状态
                        if (e.data["result"] == 0) {
                            var k: number;
                            var m: number;
                            k = PuKeMenager.four(GameViewPlay.user_accound, window.localStorage.getItem("account_id"));//k为本人所在的位置
                            m = PuKeMenager.four(GameViewPlay.user_accound, e.data["data"]["account_id"]);//m为这个玩家所在的位置
                            var jueduizhi: number;
                            if (m < k) {
                                jueduizhi = GameViewPlay.user_accound.length - k + m;
                                this.A_status(e.data["data"]["account_status"], e.data["data"], GameViewPlay.user_accound.length + m, k);
                            } else {
                                jueduizhi = m - k;
                                this.A_status(e.data["data"]["account_status"], e.data["data"], m, k);
                            }
                            //判断状态改变的玩家在线头像变亮，不在线头像变灰
                            if (e.data["data"]['online_status'] == 0) {
                                if (jueduizhi + 1 == 1) { this.touxiang1.alpha = 0.5; };
                                if (jueduizhi + 1 == 2) { this.touxiang2.alpha = 0.5; };
                                if (jueduizhi + 1 == 3) { this.touxiang3.alpha = 0.5; };
                                if (jueduizhi + 1 == 4) { this.touxiang4.alpha = 0.5; };
                                if (jueduizhi + 1 == 5) { this.touxiang5.alpha = 0.5; };
                                if (jueduizhi + 1 == 6) { this.touxiang6.alpha = 0.5; };
                            } else {
                                if (jueduizhi + 1 == 1) { this.touxiang1.alpha = 1; };
                                if (jueduizhi + 1 == 2) { this.touxiang2.alpha = 1; };
                                if (jueduizhi + 1 == 3) { this.touxiang3.alpha = 1; };
                                if (jueduizhi + 1 == 4) { this.touxiang4.alpha = 1; };
                                if (jueduizhi + 1 == 5) { this.touxiang5.alpha = 1; };
                                if (jueduizhi + 1 == 6) { this.touxiang6.alpha = 1; };
                            }
                        } else {
                            this.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, { "result_message": "内部错误，请刷新后重试！" });
                        }
                    } break;
                    case GameViewPlay.GameStart: {//游戏开始了
                        if (obj["result"] == 0) {
                            this.textready1.visible = this.textready2.visible = this.textready3.visible = this.textready4.visible = this.textready5.visible = this.textready6.visible = false;
                            if (window.localStorage.getItem("banker_mode") == "3") {//模式为抢庄时才有抢庄按钮
                                this.timenode.text = "抢庄";

                            } else {
                                this.timenode.text = "";
                            }
                            this.timergroup.visible = true;
                            this.timenumber.text = obj["limit_time"];
                            if (!this.timertest) {
                                this.timertest = new egret.Timer(1000, obj["limit_time"]);//摊牌倒计时
                            } else {
                                this.timertest.repeatCount = obj["limit_time"];
                            }
                            this.timertest.addEventListener(egret.TimerEvent.TIMER, this.TimerFunc, this);
                            this.timertest.start();

                            for (var i = 0; i < obj["data"].length; i++) {
                                if (obj["data"][i]["account_id"] == window.localStorage.getItem("account_id")) {//游戏开始即抢庄，若游戏中有本人就将准备按钮消失
                                    this.btnready.visible = false;
                                }
                                this.user_in_game[i] = obj["data"][i]["account_id"];
                            }
                        } else {
                            this.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, { "result_message": "内部错误，请刷新后重试！" });
                        }
                    } break;
                    case GameViewPlay.StartLimitTime: {//开始倒计时
                    } break;
                    case GameViewPlay.MyCards: {//用户手牌
                        if (e.data["result"] == 0) {
                            console.log(e.data['data']['cards']);
                            this.randcords[0] = PuKeMenager.four(this.pai, e.data['data']['cards'][0]) + "_png";
                            this.randcords[1] = PuKeMenager.four(this.pai, e.data['data']['cards'][1]) + "_png";
                            this.randcords[2] = PuKeMenager.four(this.pai, e.data['data']['cards'][2]) + "_png";
                            this.randcords[3] = PuKeMenager.four(this.pai, e.data['data']['cards'][3]) + "_png";
                            if (e.data['data']["account_id"] == window.localStorage.getItem("account_id") && window.localStorage.getItem("banker_mode") == "3") {//玩家存在且为抢庄时才有抢庄
                                this.ReadyTimerComFunc();//准备倒计时结束触发事件，抢庄队列按钮出现，抢庄倒计时出现
                            }
                        } else {
                            this.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, { "result_message": "内部错误，请刷新后重试！" });
                        }
                    } break;
                    case GameViewPlay.UpdateAccountMultiples: {//下注，显示玩家的注数
                        if (e.data["result"] == 0) {
                            var k: number = 0;
                            var m: number = 0;
                            var jueduizhi: number = 0;
                            m = PuKeMenager.four(GameViewPlay.user_accound, e.data["data"]["account_id"]);//m为这个玩家所在的位置
                            k = PuKeMenager.four(GameViewPlay.user_accound, window.localStorage.getItem("account_id"));//k为本人所在的位置
                            if (m < k) { jueduizhi = GameViewPlay.user_accound.length + m - k + 1; } else { jueduizhi = m - k + 1; }
                            //有庄家才显示下注注数
                            if (this.touxiang11.visible || this.touxiang22.visible || this.touxiang33.visible || this.touxiang44.visible || this.touxiang55.visible || this.touxiang66.visible) {
                                this.Multiples(jueduizhi, e.data["data"]["multiples"]);
                            }
                        } else {
                            this.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, { "result_message": "内部错误，请刷新后重试！" });
                        }
                    } break;
                    case GameViewPlay.StartBet: {//投注开始了,显示庄家
                        if (obj["result"] == 0) {
                            this.textready1.visible = this.textready2.visible = this.textready3.visible = this.textready4.visible = this.textready5.visible = this.textready6.visible = false;
                            this.QiangZhuangTimerComFunc();
                            if (window.localStorage.getItem("banker_mode") != "5") { this.setbanker(obj); }//当不为大混战时才有庄家
                            this.timenumber.text = "10";
                            this.timergroup.visible = true;
                            if (window.localStorage.getItem("banker_mode") != "5") { this.timenode.text = "闲家下注"; }
                            if (!this.timertest) {
                                this.timertest = new egret.Timer(1000, obj["limit_time"]);
                            } else {
                                this.timertest.repeatCount = obj["limit_time"];
                            }
                            this.timertest.addEventListener(egret.TimerEvent.TIMER, this.TimerFunc, this);
                            this.timertest.start();
                            for (var i = 0; i < obj["data"].length; i++) {
                                if (obj['data'][i]["account_id"] == window.localStorage.getItem("account_id") && obj['data'][i]["account_status"] > 2) {//当玩家队列里面有本人且本人游戏状态大于2
                                    if (obj['data'][i]["is_banker"] != "1" && window.localStorage.getItem("banker_mode") != "5") {//本人不是庄家且模式不为大混战时时才出现下注按钮
                                        this.xiazhu.visible = true;
                                    }
                                }
                            }
                        } else {
                            this.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, { "result_message": "内部错误，请刷新后重试！" });
                        }
                    } break;
                    case GameViewPlay.StartKickCard: {//开始踢牌,下注按钮队列消失,选牌提示框出现,提示和摊牌按钮出现
                        if (obj["result"] == 0) {
                            this.fapai(this.user_in_game);//发牌并生成保存每个人的牌
                            this.timenumber.text = obj["limit_time"];
                            this.timergroup.visible = true;
                            this.timenode.text = "选择要留的牌";
                            if (!this.timertest) {
                                this.timertest = new egret.Timer(1000, obj["limit_time"]);//摊牌倒计时
                            } else {
                                this.timertest.repeatCount = obj["limit_time"];
                            }
                            this.timertest.addEventListener(egret.TimerEvent.TIMER, this.TimerFunc, this);
                            this.timertest.start();
                        } else {
                            this.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, { "result_message": "内部错误，请刷新后重试！" });
                        }
                    } break;
                    case GameViewPlay.UpdateAccountShow: {//有玩家摊牌显示该玩家的牌和牌型
                        if (e.data["result"] == 0) {
                            var k: number;
                            var m: number;
                            var n: number;
                            k = PuKeMenager.four(GameViewPlay.user_accound, window.localStorage.getItem("account_id"));//k为本人所在的位置
                            m = PuKeMenager.four(GameViewPlay.user_accound, obj["data"]["account_id"]);//m为这个玩家所在的位置
                            if (m < k) {
                                this.A_status(8, obj["data"], (GameViewPlay.user_accound.length + m), k);
                            } else {
                                this.A_status(8, obj["data"], m, k);
                            }
                        } else {
                            this.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, { "result_message": "内部错误，请刷新后重试！" });
                        }
                    } break;
                    case GameViewPlay.StartShow: {//全部摊牌开始了
                        if (e.data["result"] == 0) {
                            this.timenumber.text = obj["limit_time"];
                            this.timergroup.visible = true;
                            this.timenode.text = "等待摊牌";
                            if (!this.timertest) {
                                this.timertest = new egret.Timer(1000, obj["limit_time"]);//摊牌倒计时
                            } else {
                                this.timertest.repeatCount = obj["limit_time"];
                            }
                            this.timertest.addEventListener(egret.TimerEvent.TIMER, this.TimerFunc, this);
                            this.timertest.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.TanPaiTimerComFunc, this);//摊牌倒计时结束触发事件，选牌提示框消失,提示和摊牌按钮消失，所有牌型图片出现
                            this.timertest.start();
                            this.showcards["id"] = [];
                            this.showcards["pai"] = [];
                            this.showcards["paixin"] = [];
                            for (var i = 0; i < obj["data"].length; i++) {
                                this.showcards["id"][i] = obj["data"][i]["account_id"];
                                if (obj["data"][i]["user_card"]) {
                                    var cards: any[] = [];
                                    cards = obj["data"][i]["user_card"][0][2];
                                    if (cards[0]["hua"] == 0) { cards[0]["hua"] = "E"; cards[0]["pai"] = "1"; }
                                    if (cards[1]["hua"] == 0) { cards[1]["hua"] = "E"; cards[1]["pai"] = "1"; }
                                    if (cards[2]["hua"] == 0) { cards[2]["hua"] = "E"; cards[2]["pai"] = "1"; }
                                    this.showcards["pai"][i] = [PuKeMenager.four(this.pai, cards[0]["hua"] + cards[0]["pai"]), PuKeMenager.four(this.pai, cards[1]["hua"] + cards[1]["pai"]), PuKeMenager.four(this.pai, cards[2]["hua"] + cards[2]["pai"])];
                                    this.showcards["paixin"][i] = [obj["data"][i]["user_card"][0][4], obj["data"][i]["user_card"][1][4]];
                                }
                            }
                        } else {
                            this.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, { "result_message": "内部错误，请刷新后重试！" });
                        }
                    } break;
                    case GameViewPlay.Win: {//获胜+积分榜，返回各玩家的比分结果,提示和摊牌按钮牌、牌型、注数消失
                        if (obj["result"] == 0) {
                            this.jushu.text = obj['data']["game_num"] + 1 + "/" + obj['data']["total_num"] + "局";
                            this.jiesuanjinbi(obj['data']);//结算金币并再开一局 
                        } else {
                            this.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, { "result_message": "内部错误，请刷新后重试！" });
                        }
                    } break;
                    case GameViewPlay.BroadcastVoice: {//发送声音
                        if (e.data["result"] == 0) {
                            //(哪个用户，哪句话，那句话的顺序号)
                            var k: number;
                            var m: number;
                            var message: string;
                            if (e.data['data']['voice_num'] == 1) { message = this.message1.text }; if (e.data['data']['voice_num'] == 2) { message = this.message2.text }; if (e.data['data']['voice_num'] == 3) { message = this.message3.text };
                            if (e.data['data']['voice_num'] == 4) { message = this.message4.text }; if (e.data['data']['voice_num'] == 5) { message = this.message5.text }; if (e.data['data']['voice_num'] == 6) { message = this.message6.text };
                            if (e.data['data']['voice_num'] == 7) { message = this.message7.text }; if (e.data['data']['voice_num'] == 8) { message = this.message8.text }; if (e.data['data']['voice_num'] == 9) { message = this.message9.text };
                            if (e.data['data']['voice_num'] == 10) { message = this.message1.text }; if (e.data['data']['voice_num'] == 11) { message = this.message11.text };
                            k = PuKeMenager.four(GameViewPlay.user_accound, window.localStorage.getItem("account_id"));//k为本人所在的位置
                            m = PuKeMenager.four(GameViewPlay.user_accound, e.data["data"]["account_id"]);//m为这个玩家所在的位置
                            if (m < k) {
                                this.showMessage(GameViewPlay.user_accound.length + m - k + 1, message, e.data['data']['voice_num']);
                            } else {
                                this.showMessage(m - k + 1, message, e.data['data']['voice_num']);
                            }
                        } else {
                            this.dispatchEventWith(GameViewPlay.ALERT_TIPS, true, { "result_message": "内部错误，请刷新后重试！" });
                        }
                    } break;
                    default: {//收到的数据不在上述情况
                        console.log(e.data)
                    } break;
                }
            }
        }
        private connectHandler(e: egret.Event): void {//soket链接建立成功后发送创建房间的数据
            this.soket.sendMessage(tool.SendData.sendJoinData());
        }
        //根据用户状态显示做相应显示
        public A_status(num: number, data, m: number, k: number) {//k本人，m状态改变的人
            if (num > 3) {
                var h = PuKeMenager.four(this.user_in_game, data["account_id"]);
                if (h == -1) { this.user_in_game.push(data["account_id"]); }
            }
            switch (num) {
                case 1: {//进入房间，显示房间内所有用户的头像和昵称和金币数
                    if (!data["nickname"]) { return; }//如果传来的数据没有用户头像昵称信息则返回
                    var nich;
                    if (data["nickname"].length > 4) {
                        nich = data["nickname"].substr(0, 4);
                    } else {
                        nich = data["nickname"];
                    }
                    if (m - k + 1 == 1) { this.user1.visible = true; this.touxiang1.source = tool.SendData.strReplace(data["headimgurl"]); this.nicheng1.text = nich; this.jinbi1.text = data["account_score"]; this.btnready.visible = true; }
                    if (m - k + 1 == 2) { this.user2.visible = true; this.touxiang2.source = tool.SendData.strReplace(data["headimgurl"]); this.nicheng2.text = nich; this.jinbi2.text = data["account_score"]; }
                    if (m - k + 1 == 3) { this.user3.visible = true; this.touxiang3.source = tool.SendData.strReplace(data["headimgurl"]); this.nicheng3.text = nich; this.jinbi3.text = data["account_score"]; }
                    if (m - k + 1 == 4) { this.user4.visible = true; this.touxiang4.source = tool.SendData.strReplace(data["headimgurl"]); this.nicheng4.text = nich; this.jinbi4.text = data["account_score"]; }
                    if (m - k + 1 == 5) { this.user5.visible = true; this.touxiang5.source = tool.SendData.strReplace(data["headimgurl"]); this.nicheng5.text = nich; this.jinbi5.text = data["account_score"]; }
                    if (m - k + 1 == 6) { this.user6.visible = true; this.touxiang6.source = tool.SendData.strReplace(data["headimgurl"]); this.nicheng6.text = nich; this.jinbi6.text = data["account_score"]; }
                } break;
                case 2: {//准备，显示已准备人的准备文字标识
                    if (m - k + 1 == 1) { this.btnready.visible = false; this.textready1.visible = true; };
                    if (m - k + 1 == 2) { this.textready2.visible = true; };
                    if (m - k + 1 == 3) { this.textready3.visible = true; };
                    if (m - k + 1 == 4) { this.textready4.visible = true; };
                    if (m - k + 1 == 5) { this.textready5.visible = true; };
                    if (m - k + 1 == 6) { this.textready6.visible = true; };
                } break;
                case 3: {//startgame
                    if (data["account_id"] == window.localStorage.getItem("account_id")) { this.btnready.visible = this.textready1.visible = false; }
                    if (data["cards"]) {
                        this.showusercards(data);//显示玩家的牌
                    }
                } break;
                case 4: {//showcards
                    if (data["account_id"] == window.localStorage.getItem("account_id")) { this.btnready.visible = this.textready1.visible = false; }
                    if (data['cards']) {
                        this.showusercards(data);//显示玩家的牌
                        var cards: any[] = data['cards'];
                        this.randcords[0] = PuKeMenager.four(this.pai, cards[0]) + "_png";
                        this.randcords[1] = PuKeMenager.four(this.pai, cards[1]) + "_png";
                        this.randcords[2] = PuKeMenager.four(this.pai, cards[2]) + "_png";
                        this.randcords[3] = PuKeMenager.four(this.pai, cards[3]) + "_png";
                    }
                } break;
                case 5: {//抢庄
                    if (data["cards"]) {
                        this.showusercards(data);//显示玩家的牌
                    }
                    if (window.localStorage.getItem("banker_mode") == "3") {
                        if (data["account_id"] == window.localStorage.getItem("account_id")) {
                            this.btnready.visible = this.textready1.visible = false;
                            this.btnqiangzhuang.visible = this.btnbuqiang.visible = true;
                        }
                        if (m - k + 1 == 1) { this.qiangzhuang1.visible = true; this.btnqiangzhuang.visible = this.btnbuqiang.visible = false; }
                        if (m - k + 1 == 2) { this.qiangzhuang2.visible = true; }
                        if (m - k + 1 == 3) { this.qiangzhuang3.visible = true; }
                        if (m - k + 1 == 4) { this.qiangzhuang4.visible = true; }
                        if (m - k + 1 == 5) { this.qiangzhuang5.visible = true; }
                        if (m - k + 1 == 6) { this.qiangzhuang6.visible = true; }
                    }
                } break;
                case 6: {//下注
                    if (data["cards"]) {
                        this.showusercards(data);//显示玩家的牌
                    }
                    if (data["account_id"] == window.localStorage.getItem("account_id")) {
                        this.btnready.visible = this.textready1.visible = this.btnqiangzhuang.visible = this.btnbuqiang.visible = false;
                        if (window.localStorage.getItem("banker_mode") != "5") { this.xiazhu.visible = true; }
                    }
                    if (data["multiples"]) {
                        if (m - k + 1 == 1) { this.Multiples(1, parseInt(data["multiples"])); }
                        if (m - k + 1 == 2) { this.Multiples(2, parseInt(data["multiples"])); }
                        if (m - k + 1 == 3) { this.Multiples(3, parseInt(data["multiples"])); }
                        if (m - k + 1 == 4) { this.Multiples(4, parseInt(data["multiples"])); }
                        if (m - k + 1 == 5) { this.Multiples(5, parseInt(data["multiples"])); }
                        if (m - k + 1 == 6) { this.Multiples(6, parseInt(data["multiples"])); }
                    }
                } break;
                case 7: {//等待推牌
                    if (data["account_id"] == window.localStorage.getItem("account_id")) {
                        this.btnready.visible = this.textready1.visible = this.btnqiangzhuang.visible = this.btnbuqiang.visible = false;
                        this.btntanpai.visible = this.btntishi.visible = true;
                    }
                    this.showusercards(data);//显示玩家的牌                   
                } break;
                case 8: {//手动摊牌
                    if (data["account_id"] == window.localStorage.getItem("account_id")) {
                        this.btnready.visible = this.textready1.visible = this.btnqiangzhuang.visible = this.btnbuqiang.visible = false;
                        this.btntanpai.visible = this.btntishi.visible = false;
                    }
                    this.tanpai(data, m, k);
                } break;
                case 9: {//全部摊牌
                    if (data["account_id"] == window.localStorage.getItem("account_id")) {
                        this.btnready.visible = this.textready1.visible = this.btnqiangzhuang.visible = this.btnbuqiang.visible = false;
                        this.btntanpai.visible = this.btntishi.visible = false;
                    }
                    this.tanpai(data, m, k);
                } break
                default: {

                } break;
            }
        }
        private tanpai(data, m, k) {
            if (data["cards"]) {
                this.showusercards(data);//显示玩家的牌
                var pai_cards: any[] = []; var n = 0;
                var cards: any[] = [];
                for (var i in data["cards"]) {
                    pai_cards[n] = PuKeMenager.four(this.pai, data["cards"][i]) + "_png";//牌资源地址
                    cards[n] = data["cards"][i];//牌型
                    if (pai_cards[n] == "-1_png") { pai_cards[n] == "card_png" }
                    n++;
                }
                if (m - k + 1 == 1) {
                    this.puke11.alpha = this.puke12.alpha = this.puke13.alpha = this.puke14.alpha = 1;
                    this.puke11.source = pai_cards[0]; this.puke12.source = pai_cards[1]; this.puke13.source = pai_cards[2];
                    this.puke14.visible = false;
                    this.paixing11.source = PuKeMenager.Puke().SanGong([PuKeMenager.four(this.pai, cards[0]), PuKeMenager.four(this.pai, cards[1]), PuKeMenager.four(this.pai, cards[2])])[0] + "_png";
                    this.paixing12.source = PuKeMenager.Puke().BiJinHua([PuKeMenager.four(this.pai, cards[0]), PuKeMenager.four(this.pai, cards[1]), PuKeMenager.four(this.pai, cards[2])])[0] + "_png";
                    this.paixing11.visible = this.paixing12.visible = true;
                }
                if (m - k + 1 == 2) {
                    this.puke21.source = pai_cards[0]; this.puke22.source = pai_cards[1]; this.puke23.source = pai_cards[2];
                    this.puke22.x = 193.12; this.puke23.x = 268.11;
                    this.puke24.visible = false;
                    this.paixing21.source = PuKeMenager.Puke().SanGong([PuKeMenager.four(this.pai, cards[0]), PuKeMenager.four(this.pai, cards[1]), PuKeMenager.four(this.pai, cards[2])])[0] + "_png";
                    this.paixing22.source = PuKeMenager.Puke().BiJinHua([PuKeMenager.four(this.pai, cards[0]), PuKeMenager.four(this.pai, cards[1]), PuKeMenager.four(this.pai, cards[2])])[0] + "_png";
                    this.paixing21.visible = this.paixing22.visible = true;
                }
                if (m - k + 1 == 3) {
                    this.puke31.source = pai_cards[0]; this.puke32.source = pai_cards[1]; this.puke33.source = pai_cards[2];
                    this.puke32.x = 193.12; this.puke33.x = 268.11;
                    this.puke34.visible = false;
                    this.paixing31.source = PuKeMenager.Puke().SanGong([PuKeMenager.four(this.pai, cards[0]), PuKeMenager.four(this.pai, cards[1]), PuKeMenager.four(this.pai, cards[2])])[0] + "_png";
                    this.paixing32.source = PuKeMenager.Puke().BiJinHua([PuKeMenager.four(this.pai, cards[0]), PuKeMenager.four(this.pai, cards[1]), PuKeMenager.four(this.pai, cards[2])])[0] + "_png";
                    this.paixing31.visible = true; this.paixing32.visible = true;
                }
                if (m - k + 1 == 4) {
                    this.puke41.source = pai_cards[0]; this.puke42.source = pai_cards[1]; this.puke43.source = pai_cards[2];
                    this.puke42.x = 193.12; this.puke43.x = 268.11;
                    this.puke44.visible = false;
                    this.paixing41.source = PuKeMenager.Puke().SanGong([PuKeMenager.four(this.pai, cards[0]), PuKeMenager.four(this.pai, cards[1]), PuKeMenager.four(this.pai, cards[2])])[0] + "_png";
                    this.paixing42.source = PuKeMenager.Puke().BiJinHua([PuKeMenager.four(this.pai, cards[0]), PuKeMenager.four(this.pai, cards[1]), PuKeMenager.four(this.pai, cards[2])])[0] + "_png";
                    this.paixing41.visible = true; this.paixing42.visible = true;
                }
                if (m - k + 1 == 5) {
                    this.puke51.source = pai_cards[0]; this.puke52.source = pai_cards[1]; this.puke53.source = pai_cards[2];
                    this.puke52.x = -17.34; this.puke53.x = -42.35;
                    this.puke54.visible = false;
                    this.paixing51.source = PuKeMenager.Puke().SanGong([PuKeMenager.four(this.pai, cards[0]), PuKeMenager.four(this.pai, cards[1]), PuKeMenager.four(this.pai, cards[2])])[0] + "_png";
                    this.paixing52.source = PuKeMenager.Puke().BiJinHua([PuKeMenager.four(this.pai, cards[0]), PuKeMenager.four(this.pai, cards[1]), PuKeMenager.four(this.pai, cards[2])])[0] + "_png";
                    this.paixing51.visible = true; this.paixing52.visible = true;
                }
                if (m - k + 1 == 6) {
                    this.puke61.source = pai_cards[0]; this.puke62.source = pai_cards[1]; this.puke63.source = pai_cards[2];
                    this.puke62.x = -17.34; this.puke63.x = -42.35;
                    this.puke64.visible = false;
                    this.paixing61.source = PuKeMenager.Puke().SanGong([PuKeMenager.four(this.pai, cards[0]), PuKeMenager.four(this.pai, cards[1]), PuKeMenager.four(this.pai, cards[2])])[0] + "_png";
                    this.paixing62.source = PuKeMenager.Puke().BiJinHua([PuKeMenager.four(this.pai, cards[0]), PuKeMenager.four(this.pai, cards[1]), PuKeMenager.four(this.pai, cards[2])])[0] + "_png";
                    this.paixing61.visible = true; this.paixing62.visible = true;
                }
            }
        }
        private fanpai() {
            egret.Tween.get(this.puke11, { onChange: this.onChange1, onChangeObj: { puke: 1, index: 1, that: this } }).to({ scaleX: 0 }, 200, egret.Ease.sineOut).to({ scaleX: 1 }, 200, egret.Ease.sineIn);
            egret.Tween.get(this.puke12, { onChange: this.onChange1, onChangeObj: { puke: 2, index: 1, that: this } }).to({ scaleX: 0 }, 200, egret.Ease.sineOut).to({ scaleX: 1 }, 200, egret.Ease.sineIn);
            egret.Tween.get(this.puke13, { onChange: this.onChange1, onChangeObj: { puke: 3, index: 1, that: this } }).to({ scaleX: 0 }, 200, egret.Ease.sineOut).to({ scaleX: 1 }, 200, egret.Ease.sineIn);
            egret.Tween.get(this.puke14, { onChange: this.onChange1, onChangeObj: { puke: 4, index: 1, that: this } }).to({ scaleX: 0 }, 200, egret.Ease.sineOut).to({ scaleX: 1 }, 200, egret.Ease.sineIn);
            this.XiaZhuTimerComFunc();//下注按钮队列消失,选牌提示框出现,提示和摊牌按钮出现
        }
        private onChange1() {
            this['index'] = this['index'] + 1;
            if (this['index'] == 15) {
                if (this["puke"] == 1) { this['that'].puke11.source = this['that'].randcords[0]; }
                if (this["puke"] == 2) { this['that'].puke12.source = this['that'].randcords[1]; }
                if (this["puke"] == 3) { this['that'].puke13.source = this['that'].randcords[2]; }
                if (this["puke"] == 4) { this['that'].puke14.source = this['that'].randcords[3]; }
            }
        }
        public Multiples(num: number, num2: number) {
            switch (num) {
                case 1: {
                    this.zhushu1.source = "bull_text_times" + num2 + "_png";
                    this.zhushu1.visible = true;
                } break;
                case 2: {
                    this.zhushu2.source = "bull_text_times" + num2 + "_png";
                    this.zhushu2.visible = true;
                } break;
                case 3: {
                    this.zhushu3.source = "bull_text_times" + num2 + "_png";
                    this.zhushu3.visible = true;
                } break;
                case 4: {
                    this.zhushu4.source = "bull_text_times" + num2 + "_png";
                    this.zhushu4.visible = true;
                } break;
                case 5: {
                    this.zhushu5.source = "bull_text_times" + num2 + "_png";
                    this.zhushu5.visible = true;
                } break;
                case 6: {
                    this.zhushu6.source = "bull_text_times" + num2 + "_png";
                    this.zhushu6.visible = true;
                } break;
                default: {
                } break;
            }
        }
        protected createChildren(): void {
            super.createChildren();
            this.btnnote.addEventListener(egret.TouchEvent.TOUCH_TAP, this.ShowNode, this)//提示
            this.btnrule.addEventListener(egret.TouchEvent.TOUCH_TAP, this.ShowRule, this)//规则
            this.btnhome.addEventListener(egret.TouchEvent.TOUCH_TAP, this.GoHOME, this)//返回大厅
            this.btnmessage.addEventListener(egret.TouchEvent.TOUCH_TAP, this.SendMessage, this)//发消息
            this.btnsound.addEventListener(egret.TouchEvent.TOUCH_TAP, this.SetSound, this)//设置声音
            this.btnready.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchReady, this)//准备按钮
            this.btnqiangzhuang.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchQiangZhuang, this)//抢庄按钮
            this.btnbuqiang.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchBuQiang, this)//不抢庄按钮
            this.btntishi.addEventListener(egret.TouchEvent.TOUCH_TAP, this.TiShi, this)//提示按钮
            this.btntanpai.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchTabPai, this)//摊牌按钮
            this.btnone.addEventListener(egret.TouchEvent.TOUCH_TAP, this.XiaZhu1, this);//下注数目
            this.btntwo.addEventListener(egret.TouchEvent.TOUCH_TAP, this.XiaZhu2, this);
            this.btnthree.addEventListener(egret.TouchEvent.TOUCH_TAP, this.XiaZhu3, this);
            this.btnfour.addEventListener(egret.TouchEvent.TOUCH_TAP, this.XiaZhu4, this);
            this.btnfive.addEventListener(egret.TouchEvent.TOUCH_TAP, this.XiaZhu5, this);
            this.linkbtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.copylink, this);
        }
        private copylink(e: egret.TouchEvent): void {
            var str = location.href; //取得整个地址栏
            var num = str.indexOf("?")
            var href: string;
            if (num != -1) {
                href = str.substring(0, num);
            } else {
                href = str;
            }
            GameViewPlay.copy(href + "?room_id=" + window.localStorage.getItem("room_number"));
        }
        private onClickTouchReady(e: egret.TouchEvent): void {
            this.btnready.visible = false; this.textready1.visible = true;
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendReadyStartData());
            }
        }
        private onClickTouchQiangZhuang(e: egret.TouchEvent): void {
            this.qiangzhuang1.visible = true;
            this.btnqiangzhuang.visible = this.btnbuqiang.visible = false;
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendGrabBankerData(1, 1));
            }
        }
        private onClickTouchBuQiang(e: egret.TouchEvent): void {
            this.btnqiangzhuang.visible = this.btnbuqiang.visible = false;
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendGrabBankerData(0, 1));
            }
        }
        private onClickTouchTabPai(e: egret.TouchEvent = null): void {//摊牌按钮点击后，摊牌按钮无效，摊牌按钮和提示按钮和提示文字消失,不可以点选牌去掉选中的牌并整理牌的位置,发送选中的牌,自己的牌型出现
            this.btntanpai.enabled = false;
            this.btntanpai.visible = this.btntishi.visible = this.tishi.visible = false;
            this.timergroup.visible = this.btntanpai.visible = this.btntishi.visible = this.tishi.visible = false;
            this.bipai();//不可以点选牌,发送踢牌信息
            var sleeptimer = new egret.Timer(800, 1);
            sleeptimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, function () { this.soket.sendMessage(tool.SendData.sendShowCardData()); }, this)
            sleeptimer.start();
        }

        private XiaZhu1(e: egret.TouchEvent): void {
            this.xiazhu.visible = false
            this.zhushu1.source = "bull_text_times1_png"
            this.zhushu1.visible = true
            this.soket.sendMessage(tool.SendData.sendPlayerMultiplesData(1));
        }
        private XiaZhu2(e: egret.TouchEvent): void {
            this.xiazhu.visible = false
            this.zhushu1.source = "bull_text_times2_png"
            this.zhushu1.visible = true
            this.soket.sendMessage(tool.SendData.sendPlayerMultiplesData(2));
        }
        private XiaZhu3(e: egret.TouchEvent): void {
            this.xiazhu.visible = false
            this.zhushu1.source = "bull_text_times3_png"
            this.zhushu1.visible = true
            this.soket.sendMessage(tool.SendData.sendPlayerMultiplesData(3));
        }
        private XiaZhu4(e: egret.TouchEvent): void {
            this.xiazhu.visible = false
            this.zhushu1.source = "bull_text_times4_png"
            this.zhushu1.visible = true
            this.soket.sendMessage(tool.SendData.sendPlayerMultiplesData(4));
        }
        private XiaZhu5(e: egret.TouchEvent): void {
            this.xiazhu.visible = false
            this.zhushu1.source = "bull_text_times5_png"
            this.zhushu1.visible = true
            this.soket.sendMessage(tool.SendData.sendPlayerMultiplesData(5));
        }
        private ShowNode(e: egret.TouchEvent): void {//提示按钮
            this.dispatchEventWith("showtishi");
        }
        private ShowRule(e: egret.TouchEvent): void {//规则按钮
            this.dispatchEventWith("showrule");
        }
        private GoHOME(e: egret.TouchEvent): void {//返回大厅按钮
            this.dispatchEventWith("backhome");
        }
        private SendMessage(e: egret.TouchEvent): void {//发送消息按钮
            if (this.sendmessage.visible) {
                this.sendmessage.visible = false
            } else {
                this.sendmessage.visible = true
                this.message1.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchSendMessage1, this)
                this.message2.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchSendMessage2, this)
                this.message3.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchSendMessage3, this)
                this.message4.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchSendMessage4, this)
                this.message5.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchSendMessage5, this)
                this.message6.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchSendMessage6, this)
                this.message7.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchSendMessage7, this)
                this.message8.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchSendMessage8, this)
                this.message9.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchSendMessage9, this)
                this.message10.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchSendMessage10, this)
                this.message11.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickTouchSendMessage11, this)
            }
        }
        private onClickTouchSendMessage1(e: egret.TouchEvent): void {
            this.sendmessage.visible = false; this.usermessagegroup1.visible = true; SoundMenager.Shared().PlayWord1(); this.usermessage1.text = this.message1.text;
            var messagetimer: egret.Timer = new egret.Timer(1000, 10);
            messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this);
            messagetimer.start();
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendBroadcastVoiceData(1));
            }
        }
        private onClickTouchSendMessage2(e: egret.TouchEvent): void {
            this.sendmessage.visible = false; this.usermessagegroup1.visible = true; SoundMenager.Shared().PlayWord2(); this.usermessage1.text = this.message2.text;
            var messagetimer: egret.Timer = new egret.Timer(1000, 10);
            messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this);
            messagetimer.start();
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendBroadcastVoiceData(2));
            }
        }
        private onClickTouchSendMessage3(e: egret.TouchEvent): void {
            this.sendmessage.visible = false; this.usermessagegroup1.visible = true; SoundMenager.Shared().PlayWord3(); this.usermessage1.text = this.message3.text;
            var messagetimer: egret.Timer = new egret.Timer(1000, 10);
            messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this);
            messagetimer.start();
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendBroadcastVoiceData(3));
            }
        }
        private onClickTouchSendMessage4(e: egret.TouchEvent): void {
            this.sendmessage.visible = false; this.usermessagegroup1.visible = true; SoundMenager.Shared().PlayWord4(); this.usermessage1.text = this.message4.text;
            var messagetimer: egret.Timer = new egret.Timer(1000, 10);
            messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this);
            messagetimer.start();
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendBroadcastVoiceData(4));
            }
        }
        private onClickTouchSendMessage5(e: egret.TouchEvent): void {
            this.sendmessage.visible = false; this.usermessagegroup1.visible = true; SoundMenager.Shared().PlayWord5(); this.usermessage1.text = this.message5.text;
            var messagetimer: egret.Timer = new egret.Timer(1000, 10);
            messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this);
            messagetimer.start();
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendBroadcastVoiceData(5));
            }
        }
        private onClickTouchSendMessage6(e: egret.TouchEvent): void {
            this.sendmessage.visible = false; this.usermessagegroup1.visible = true; SoundMenager.Shared().PlayWord6(); this.usermessage1.text = this.message6.text;
            var messagetimer: egret.Timer = new egret.Timer(1000, 10);
            messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this);
            messagetimer.start();
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendBroadcastVoiceData(6));
            }
        }
        private onClickTouchSendMessage7(e: egret.TouchEvent): void {
            this.sendmessage.visible = false; this.usermessagegroup1.visible = true; SoundMenager.Shared().PlayWord7(); this.usermessage1.text = this.message7.text;
            var messagetimer: egret.Timer = new egret.Timer(1000, 10);
            messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this);
            messagetimer.start();
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendBroadcastVoiceData(7));
            }
        }
        private onClickTouchSendMessage8(e: egret.TouchEvent): void {
            this.sendmessage.visible = false; this.usermessagegroup1.visible = true; SoundMenager.Shared().PlayWord8(); this.usermessage1.text = this.message8.text;
            var messagetimer: egret.Timer = new egret.Timer(1000, 10);
            messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this);
            messagetimer.start();
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendBroadcastVoiceData(8));
            }
        }
        private onClickTouchSendMessage9(e: egret.TouchEvent): void {
            this.sendmessage.visible = false; this.usermessagegroup1.visible = true; SoundMenager.Shared().PlayWord9(); this.usermessage1.text = this.message9.text;
            var messagetimer: egret.Timer = new egret.Timer(1000, 10);
            messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this);
            messagetimer.start();
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendBroadcastVoiceData(9));
            }
        }
        private onClickTouchSendMessage10(e: egret.TouchEvent): void {
            this.sendmessage.visible = false; this.usermessagegroup1.visible = true; SoundMenager.Shared().PlayWord10(); this.usermessage1.text = this.message10.text;
            var messagetimer: egret.Timer = new egret.Timer(1000, 10);
            messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this);
            messagetimer.start();
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendBroadcastVoiceData(10));
            }
        }
        private onClickTouchSendMessage11(e: egret.TouchEvent): void {
            this.sendmessage.visible = false; this.usermessagegroup1.visible = true; SoundMenager.Shared().PlayWord11(); this.usermessage1.text = this.message11.text;
            var messagetimer: egret.Timer = new egret.Timer(1000, 10);
            messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this);
            messagetimer.start();
            if (this.soket) {
                this.soket.sendMessage(tool.SendData.sendBroadcastVoiceData(11));
            }
        }
        //在哪个玩家上显示哪句话(哪个用户，哪句话，那句话的顺序号)
        private showMessage(num1: number, message: string, num2: number) {
            var messagetimer: egret.Timer = new egret.Timer(1000, 10);
            if (num1 == 1) { this.usermessagegroup1.visible = true; this.usermessage1.text = message; this.messageplay(num2); messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this); }
            else if (num1 == 2) { this.usermessagegroup2.visible = true; this.usermessage2.text = message; this.messageplay(num2); messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this); }
            else if (num1 == 3) { this.usermessagegroup3.visible = true; this.usermessage3.text = message; this.messageplay(num2); messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this); }
            else if (num1 == 4) { this.usermessagegroup4.visible = true; this.usermessage4.text = message; this.messageplay(num2); messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this); }
            else if (num1 == 5) { this.usermessagegroup5.visible = true; this.usermessage5.text = message; this.messageplay(num2); messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this); }
            else { this.usermessagegroup6.visible = true; this.usermessage6.text = message; this.messageplay(num2); messagetimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.distorymessage, this); }
            messagetimer.start();
        }
        private messageplay(number: number) {
            if (number == 1) { SoundMenager.Shared().PlayWord1() }
            if (number == 2) { SoundMenager.Shared().PlayWord2() }
            if (number == 3) { SoundMenager.Shared().PlayWord3() }
            if (number == 4) { SoundMenager.Shared().PlayWord4() }
            if (number == 5) { SoundMenager.Shared().PlayWord5() }
            if (number == 6) { SoundMenager.Shared().PlayWord6() }
            if (number == 7) { SoundMenager.Shared().PlayWord7() }
            if (number == 8) { SoundMenager.Shared().PlayWord8() }
            if (number == 9) { SoundMenager.Shared().PlayWord9() }
            if (number == 10) { SoundMenager.Shared().PlayWord10() }
            if (number == 11) { SoundMenager.Shared().PlayWord11() }
        }
        private distorymessage(event: egret.TimerEvent) {
            this.usermessagegroup1.visible = this.usermessagegroup2.visible = this.usermessagegroup3.visible = this.usermessagegroup4.visible = this.usermessagegroup5.visible = this.usermessagegroup6.visible = false;
            var ti = event.currentTarget as egret.Timer;
            ti.reset();
        }
        private SetSound(e: egret.TouchEvent): void {//设置声音按钮
            this.dispatchEventWith("showsound");
        }
        private TiShi(e: egret.TouchEvent = null): void {//提示按钮按下事件
            var str1: string = this.randcords[0];
            var str2: string = this.randcords[1];
            var str3: string = this.randcords[2];
            var str4: string = this.randcords[3];
            var temp1 = str1.split("_");
            var temp2 = str2.split("_");
            var temp3 = str3.split("_");
            var temp4 = str4.split("_");
            console.error(temp1, temp2, temp3, temp4);
            var tishinumber: number = PuKeMenager.Puke().TiShi([parseInt(temp1[0]), parseInt(temp2[0]), parseInt(temp3[0]), parseInt(temp4[0])]);
            if (tishinumber == 1) { this.puke11.alpha = 0.5; this.puke12.alpha = 1; this.puke13.alpha = 1; this.puke14.alpha = 1; }
            if (tishinumber == 2) { this.puke11.alpha = 1; this.puke12.alpha = 0.5; this.puke13.alpha = 1; this.puke14.alpha = 1; }
            if (tishinumber == 3) { this.puke11.alpha = 1; this.puke12.alpha = 1; this.puke13.alpha = 0.5; this.puke14.alpha = 1; }
            if (tishinumber == 4) { this.puke11.alpha = 1; this.puke12.alpha = 1; this.puke13.alpha = 1; this.puke14.alpha = 0.5; }
            this.btntanpai.enabled = true
        }
        private QiangZhuangTimer: egret.Timer
        private ReadyTimerComFunc() {//准备倒计时结束触发事件，准备文字消失，抢庄队列按钮出现，抢庄倒计时出现
            this.timergroup.visible = this.btnqiangzhuang.visible = this.btnbuqiang.visible = true;
        }
        private QiangZhuangTimerComFunc(event: egret.TimerEvent = null) {//抢庄倒计时结束触发事件，抢庄按钮队列消失，抢庄按钮消失
            this.timergroup.visible = false;
            this.btnqiangzhuang.visible = this.btnbuqiang.visible = false;
        }
        private XiaZhuTimerComFunc() {//闲家下注倒计时结束触发事件，下注按钮队列消失, 选牌提示框出现,提示和摊牌按钮出现
            this.xiazhu.visible = false
            this.tishi.visible = this.btntishi.visible = this.btntanpai.visible = true

            this.puke11.addEventListener(egret.TouchEvent.TOUCH_TAP, this.dianxuan1, this)//可以点选牌
            this.puke12.addEventListener(egret.TouchEvent.TOUCH_TAP, this.dianxuan2, this)
            this.puke13.addEventListener(egret.TouchEvent.TOUCH_TAP, this.dianxuan3, this)
            this.puke14.addEventListener(egret.TouchEvent.TOUCH_TAP, this.dianxuan4, this)
        }
        private dianxuan1() { this.puke11.alpha = 0.5; this.puke12.alpha = 1; this.puke13.alpha = 1; this.puke14.alpha = 1; this.btntanpai.enabled = true; }
        private dianxuan2() { this.puke11.alpha = 1; this.puke12.alpha = 0.5; this.puke13.alpha = 1; this.puke14.alpha = 1; this.btntanpai.enabled = true; }
        private dianxuan3() { this.puke11.alpha = 1; this.puke12.alpha = 1; this.puke13.alpha = 0.5; this.puke14.alpha = 1; this.btntanpai.enabled = true; }
        private dianxuan4() { this.puke11.alpha = 1; this.puke12.alpha = 1; this.puke13.alpha = 1; this.puke14.alpha = 0.5; this.btntanpai.enabled = true; }
        private TimerFunc(event: egret.TimerEvent) {//倒计时每次触发事件
            var num: any = parseInt(this.timenumber.text) - 1;
            this.timenumber.text = "" + num;
            if (parseInt(this.timenumber.text) == 0 || parseInt(this.timenumber.text) < 0) {
                this.timenumber.text = "10";
                if (!this.timertest) {
                    this.timertest = new egret.Timer(1000, 10);//摊牌倒计时
                } else {
                    this.timertest.repeatCount = 10;
                }
                this.timertest.addEventListener(egret.TimerEvent.TIMER, this.TimerFunc, this);
                this.timertest.start();
            }
        }
        private TanPaiTimerComFunc(event: egret.TimerEvent = null) {//选牌提示框消失,提示和摊牌按钮消失，所有牌型图片出现
            var ti = event.currentTarget as egret.Timer;
            ti.reset();
            ti.removeEventListener(egret.TimerEvent.TIMER_COMPLETE, this.TanPaiTimerComFunc, this);

            this.btntanpai.enabled = false;
            this.btntanpai.visible = this.btntishi.visible = this.tishi.visible = false;
            this.timergroup.visible = this.btntanpai.visible = this.btntishi.visible = this.tishi.visible = false;
            this.puke14.visible = this.puke24.visible = this.puke34.visible = this.puke44.visible = this.puke54.visible = this.puke64.visible = false;
            var k: number;
            var m: number;
            k = PuKeMenager.four(GameViewPlay.user_accound, window.localStorage.getItem("account_id"));//k为本人所在的位置
            for (var i = 0; i < this.showcards["pai"].length; i++) {
                m = PuKeMenager.four(GameViewPlay.user_accound, this.showcards["id"][i]);//m为这个玩家所在的位置
                if (m < k) { m = GameViewPlay.user_accound.length + m; }
                if (m - k + 1 == 1) {
                    this.puke11.alpha = this.puke12.alpha = this.puke13.alpha = this.puke14.alpha = 1;
                    this.puke11.source = this.showcards["pai"][i][0] + "_png"; this.puke12.source = this.showcards["pai"][i][1] + "_png"; this.puke13.source = this.showcards["pai"][i][2] + "_png";
                    this.puke14.visible = false;
                    this.paixing12.source = this.showcards["paixin"][i][1] + "_png"; this.paixing11.source = this.showcards["paixin"][i][0] + "_png";
                    this.paixing11.visible = this.paixing12.visible = true;
                }
                if (m - k + 1 == 2) {
                    this.puke21.source = this.showcards["pai"][i][0] + "_png"; this.puke22.source = this.showcards["pai"][i][1] + "_png"; this.puke23.source = this.showcards["pai"][i][2] + "_png";
                    this.puke22.x = 193.12; this.puke23.x = 268.11;
                    this.puke24.visible = false;
                    this.paixing22.source = this.showcards["paixin"][i][1] + "_png"; this.paixing21.source = this.showcards["paixin"][i][0] + "_png";
                    this.paixing21.visible = this.paixing22.visible = true;
                }
                if (m - k + 1 == 3) {
                    this.puke31.source = this.showcards["pai"][i][0] + "_png"; this.puke32.source = this.showcards["pai"][i][1] + "_png"; this.puke33.source = this.showcards["pai"][i][2] + "_png";
                    this.puke32.x = 193.12; this.puke33.x = 268.11;
                    this.puke34.visible = false;
                    this.paixing32.source = this.showcards["paixin"][i][1] + "_png"; this.paixing31.source = this.showcards["paixin"][i][0] + "_png";
                    this.paixing31.visible = this.paixing32.visible = true;
                }
                if (m - k + 1 == 4) {
                    this.puke41.source = this.showcards["pai"][i][0] + "_png"; this.puke42.source = this.showcards["pai"][i][1] + "_png"; this.puke43.source = this.showcards["pai"][i][2] + "_png";
                    this.puke42.x = 193.12; this.puke43.x = 268.11;
                    this.puke44.visible = false;
                    this.paixing42.source = this.showcards["paixin"][i][1] + "_png"; this.paixing41.source = this.showcards["paixin"][i][0] + "_png";
                    this.paixing41.visible = this.paixing42.visible = true;
                }
                if (m - k + 1 == 5) {
                    this.puke51.source = this.showcards["pai"][i][0] + "_png"; this.puke52.source = this.showcards["pai"][i][1] + "_png"; this.puke53.source = this.showcards["pai"][i][2] + "_png";
                    this.puke52.x = -17.34; this.puke53.x = -42.35;
                    this.puke54.visible = false;
                    this.paixing52.source = this.showcards["paixin"][i][1] + "_png"; this.paixing51.source = this.showcards["paixin"][i][0] + "_png";
                    this.paixing51.visible = this.paixing52.visible = true;
                }
                if (m - k + 1 == 6) {
                    this.puke61.source = this.showcards["pai"][i][0] + "_png"; this.puke62.source = this.showcards["pai"][i][1] + "_png"; this.puke63.source = this.showcards["pai"][i][2] + "_png";
                    this.puke62.x = -17.34; this.puke63.x = -42.35;
                    this.puke64.visible = false;
                    this.paixing62.source = this.showcards["paixin"][i][1] + "_png"; this.paixing61.source = this.showcards["paixin"][i][0] + "_png";
                    this.paixing61.visible = this.paixing62.visible = true;
                }
            }
        }
        private cardsmove(img: eui.Image, obj, objValue, t, count) {
            var ease: Function = egret.Ease.sineIn;
            if ((count - 1) % 4 == 0 && count != 1) {
                if ((count - 1) == 4) {
                    egret.Tween.get(img, { loop: false, onChangeObj: this }).to(obj, 300, ease).wait(t).call(this.fanpai, this, []);//第一个人的牌发完就调用fanpai函数
                } else {
                    egret.Tween.get(img, { loop: false, onChangeObj: this }).to(obj, 300, ease);
                }
            } else {
                if (img && obj && t) {
                    egret.Tween.get(img, { loop: false, onChange: this.onChange, onChangeObj: objValue }).to(obj, 300, ease)//.wait(t).call(this.effectComplete, this, [count, objValue]);
                }
            }
        }
        private onChange(e) {
            this['index'] = this['index'] + 1;
            var count = this["count"];
            var that = this["that"];
            if (((count - 1) % 4) != 0) {//count为一个人的牌的张数，当可以被4整除的即一个人的牌发完不再发牌
                var obj = RES.getRes("config_json");
                if (this['index'] % 12 == 0) {//onChange函数调用次数是2的倍数就发下一张牌
                    if (obj && obj[count]) {
                        var item = obj[count]
                        var temp = this["count"] + 1;;
                        this["count"] = temp;
                        // that[item.name].visible = true;
                        // console.error("======", item.name, item.data)
                        that.cardsmove(that[item.name], item.data, this, 600, temp);

                    }
                }
            }
        }
        private moves(count, objValue) {//count为要发牌的张数           
            var obj = RES.getRes("config_json");
            if (obj && obj[count]) {
                var item = obj[count]
                var temp = count + 1;
                objValue.count = temp
                // this[item.name].visible = true;
                // console.error(item.name)
                this.cardsmove(this[item.name], item.data, objValue, 600, temp);
            }
        }
        private showusercards(data) {
            var id = [];
            var m = PuKeMenager.four(GameViewPlay.user_accound, window.localStorage.getItem("account_id"));//本人所在index
            var other;
            for (var k = 0; k < GameViewPlay.user_accound.length; k++) {
                other = PuKeMenager.four(GameViewPlay.user_accound, GameViewPlay.user_accound[k]);//别人所在index
                if (other < m) {//将玩家ID按本机座位顺序排序
                    id[GameViewPlay.user_accound.length - m + other] = GameViewPlay.user_accound[k];
                } else {
                    id[other - m] = GameViewPlay.user_accound[k];
                }
            }
            this.deletecards(id, this.user_in_game);
            var jslength = 0;
            if (!data["cards"]) {//如果牌不存在的话
                return;
            } else {
                for (var js2 in data["cards"]) {
                    jslength++;
                }
            }
            var cards: any[] = data['cards'];
            this.randcords[0] = PuKeMenager.four(this.pai, cards[0]) + "_png";
            this.randcords[1] = PuKeMenager.four(this.pai, cards[1]) + "_png";
            this.randcords[2] = PuKeMenager.four(this.pai, cards[2]) + "_png";
            this.randcords[3] = PuKeMenager.four(this.pai, cards[3]) + "_png";
            var k = PuKeMenager.four(GameViewPlay.user_accound, window.localStorage.getItem("account_id"));//k为本人所在的位置
            var m = PuKeMenager.four(GameViewPlay.user_accound, data["account_id"]);//m为这个玩家所在的位置
            var jueduizhi;
            if (m < k) {
                jueduizhi = GameViewPlay.user_accound.length - k + m;
            } else {
                jueduizhi = m - k
            }
            if (jueduizhi == 0) {
                this.cards_weizhi(1);
                this.textready1.visible = false;
                this.puke11.visible = this.puke12.visible = this.puke13.visible = this.puke14.visible = true;
                this.puke11.source = this.randcords[0];
                this.puke12.source = this.randcords[1];
                this.puke13.source = this.randcords[2];
                if (this.randcords[3] != "-1_png") { this.puke14.source = this.randcords[3]; }
                if (data["account_status"] > 7 || jslength == 3) {//处于摊牌状态
                    this.puke14.visible = false;
                }
            }
            if (jueduizhi == 1) {
                this.cards_weizhi(5);
                this.textready2.visible = false;
                this.puke21.visible = this.puke22.visible = this.puke23.visible = this.puke24.visible = true;
                if (data["account_status"] > 7 || jslength == 3) {//处于摊牌状态
                    this.puke22.x = 193.12; this.puke23.x = 268.11;
                    this.puke24.visible = false;
                }
            }
            if (jueduizhi == 2) {
                this.cards_weizhi(9);
                this.textready3.visible = false;
                this.puke31.visible = this.puke32.visible = this.puke33.visible = this.puke34.visible = true;
                if (data["account_status"] > 7 || jslength == 3) {//处于摊牌状态
                    this.puke32.x = 193.12; this.puke33.x = 268.11;
                    this.puke34.visible = false;
                }
            }
            if (jueduizhi == 3) {
                this.cards_weizhi(13);
                this.textready4.visible = false;
                this.puke41.visible = this.puke42.visible = this.puke43.visible = this.puke44.visible = true;
                if (data["account_status"] > 7 || jslength == 3) {//处于摊牌状态
                    this.puke42.x = 193.12; this.puke43.x = 268.11;
                    this.puke44.visible = false;
                }
            }
            if (jueduizhi == 4) {
                this.cards_weizhi(17);
                this.textready5.visible = false;
                this.puke51.visible = this.puke52.visible = this.puke53.visible = this.puke54.visible = true;
                if (data["account_status"] > 7 || jslength == 3) {//处于摊牌状态
                    this.puke52.x = -17.34; this.puke53.x = -42.35;
                    this.puke54.visible = false;
                }
            }
            if (jueduizhi == 5) {
                this.cards_weizhi(21);
                this.textready6.visible = false;
                this.puke61.visible = this.puke62.visible = this.puke63.visible = this.puke64.visible = true;
                if (data["account_status"] > 7 || jslength == 3) {//处于摊牌状态
                    this.puke62.x = -17.34; this.puke63.x = -42.35;
                    this.puke64.visible = false;
                }
            }
        }
        private deletecards(id, startmenmb) {  //将玩家ID按本机座位顺序排序  
            if (startmenmb.length == 0) {//startmen为已有玩家
                return;
            }
            for (var i = 0; i < GameViewPlay.user_accound.length; i++) {
                var k = PuKeMenager.four(startmenmb, GameViewPlay.user_accound[i])//判断GameViewPlay.user_accound[i]是否正在游戏
                if (k == -1) {
                    // console.error(GameViewPlay.user_accound[i],"=====牌消失========",startmenmb)
                    var n = PuKeMenager.four(id, GameViewPlay.user_accound[i])//ID为目前的座位顺序排序，然后找到传来的用户所在的位置给其发牌
                    if (n == 1) { this.puke11.visible = this.puke12.visible = this.puke13.visible = this.puke14.visible = false; }
                    if (n == 2) { this.puke21.visible = this.puke22.visible = this.puke23.visible = this.puke24.visible = false; }
                    if (n == 3) { this.puke31.visible = this.puke32.visible = this.puke33.visible = this.puke34.visible = false; }
                    if (n == 4) { this.puke41.visible = this.puke42.visible = this.puke43.visible = this.puke44.visible = false; }
                    if (n == 5) { this.puke51.visible = this.puke52.visible = this.puke53.visible = this.puke54.visible = false; }
                    if (n == 6) { this.puke61.visible = this.puke62.visible = this.puke63.visible = this.puke64.visible = false; }
                }
            }
        }
        private fapai(startmenmb) {
            var id = [];
            var m = PuKeMenager.four(GameViewPlay.user_accound, window.localStorage.getItem("account_id"));//本人所在index
            var other;
            for (var k = 0; k < GameViewPlay.user_accound.length; k++) {
                other = PuKeMenager.four(GameViewPlay.user_accound, GameViewPlay.user_accound[k]);//别人所在index
                if (other < m) {//将玩家ID按本机座位顺序排序
                    id[GameViewPlay.user_accound.length - m + other] = GameViewPlay.user_accound[k];
                } else {
                    id[other - m] = GameViewPlay.user_accound[k];
                }
            }
            this.deletecards(id, startmenmb);
            for (var i = 0; i < startmenmb.length; i++) {
                var m = PuKeMenager.four(id, startmenmb[i])//对传来的用户数组循环匹配，先将ID按目前的座位顺序排序，然后找到传来的用户所在的位置给其发牌
                if (m == 1) {
                    this.puke11.visible = this.puke12.visible = this.puke13.visible = this.puke14.visible = true;
                    this.moves(1, { srot: 1, count: 1, index: 0, that: this });
                }
                if (m == 2) {
                    this.textready2.visible = false;
                    this.puke21.visible = this.puke22.visible = this.puke23.visible = this.puke24.visible = true;
                    this.moves(5, { srot: 2, count: 5, index: 0, that: this });
                }
                if (m == 3) {
                    this.textready3.visible = false;
                    this.puke31.visible = this.puke32.visible = this.puke33.visible = this.puke34.visible = true;
                    this.moves(9, { srot: 3, count: 9, index: 0, that: this });
                }
                if (m == 4) {
                    this.puke41.visible = this.puke42.visible = this.puke43.visible = this.puke44.visible = true;
                    this.textready4.visible = false;
                    this.moves(13, { srot: 4, count: 13, index: 0, that: this });
                }
                if (m == 5) {
                    this.puke51.visible = this.puke52.visible = this.puke53.visible = this.puke54.visible = true;
                    this.textready5.visible = false;
                    this.moves(17, { srot: 5, count: 17, index: 0, that: this });
                }
                if (m == 6) {
                    this.puke61.visible = this.puke62.visible = this.puke63.visible = this.puke64.visible = true;
                    this.textready6.visible = false;
                    this.moves(21, { srot: 6, count: 21, index: 0, that: this });
                }
            }
        }
        private setbanker(data: {}) {//自由抢庄时随机获得庄家的效果
            this.btnqiangzhuang.visible = this.btnbuqiang.visible = false;
            this.zhushu1.visible = this.zhushu2.visible = this.zhushu3.visible = this.zhushu4.visible = this.zhushu5.visible = this.zhushu6.visible = false;
            this.qiangzhuang1.visible = this.qiangzhuang2.visible = this.qiangzhuang3.visible = this.qiangzhuang4.visible = this.qiangzhuang5.visible = this.qiangzhuang6.visible = false;
            var theone;
            for (var i = 0; i < data["data"].length; i++) {
                if (data["data"][i]["is_banker"] == 1) {
                    theone = data["data"][i]["account_id"];
                    break;
                }
            }
            var m: number = PuKeMenager.four(GameViewPlay.user_accound, theone);//庄家所在的位置
            var k: number = PuKeMenager.four(GameViewPlay.user_accound, window.localStorage.getItem("account_id"));//本人所在的位置
            if (m < k) { theone = GameViewPlay.user_accound.length + m - k + 1; } else { theone = m - k + 1; }
            var BankerTimer: egret.Timer = new egret.Timer(300, 6);//庄家倒计时
            BankerTimer["theone"] = theone;
            BankerTimer.addEventListener(egret.TimerEvent.TIMER, this.setbankerTimerFunc, this);
            BankerTimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.setbankerTimerComFunc, this);
            BankerTimer.start();
        }
        private setbankerTimerFunc(event: egret.TimerEvent) {//庄家倒计时每次触发事件
            var num: number = Math.round(Math.random() * this.user_in_game.length)
            if (num == 1) { this.touxiang11.visible = true; this.touxiang22.visible = false; this.touxiang33.visible = false; this.touxiang44.visible = false; this.touxiang55.visible = false; this.touxiang66.visible = false; }
            if (num == 2) { this.touxiang11.visible = false; this.touxiang22.visible = true; this.touxiang33.visible = false; this.touxiang44.visible = false; this.touxiang55.visible = false; this.touxiang66.visible = false; }
            if (num == 3) { this.touxiang11.visible = false; this.touxiang22.visible = false; this.touxiang33.visible = true; this.touxiang44.visible = false; this.touxiang55.visible = false; this.touxiang66.visible = false; }
            if (num == 4) { this.touxiang11.visible = false; this.touxiang22.visible = false; this.touxiang33.visible = false; this.touxiang44.visible = true; this.touxiang55.visible = false; this.touxiang66.visible = false; }
            if (num == 5) { this.touxiang11.visible = false; this.touxiang22.visible = false; this.touxiang33.visible = false; this.touxiang44.visible = false; this.touxiang55.visible = true; this.touxiang66.visible = false; }
            if (num == 6) { this.touxiang11.visible = false; this.touxiang22.visible = false; this.touxiang33.visible = false; this.touxiang44.visible = false; this.touxiang55.visible = false; this.touxiang66.visible = true; }
        }
        private setbankerTimerComFunc(event: egret.TimerEvent) {
            //所有抢庄文字消失
            this.touxiang11.visible = this.touxiang22.visible = false; this.touxiang33.visible = false; this.touxiang44.visible = false; this.touxiang55.visible = false; this.touxiang66.visible = false;
            var theone = event.currentTarget["theone"]
            if (theone == 1) { this.touxiang11.visible = true; this.zhuang1.visible = true; }
            if (theone == 2) { this.touxiang22.visible = true; this.zhuang2.visible = true; }
            if (theone == 3) { this.touxiang33.visible = true; this.zhuang3.visible = true; }
            if (theone == 4) { this.touxiang44.visible = true; this.zhuang4.visible = true; }
            if (theone == 5) { this.touxiang55.visible = true; this.zhuang5.visible = true; }
            if (theone == 6) { this.touxiang66.visible = true; this.zhuang6.visible = true; }
        }
        private bipai() {//不可以点选牌,发送踢牌信息
            this.puke11.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.dianxuan1, this)//不可以点选牌
            this.puke12.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.dianxuan2, this)
            this.puke13.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.dianxuan3, this)
            this.puke14.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.dianxuan4, this)
            var kickcard = "";
            if (this.puke11.alpha == 0.5) { var p = this.puke11.source + ""; var temp = p.split("_"); var inde = parseInt(temp[0]) - 1; kickcard = this.pai[inde]; }
            if (this.puke12.alpha == 0.5) { var p = this.puke12.source + ""; var temp = p.split("_"); var inde = parseInt(temp[0]) - 1; kickcard = this.pai[inde]; }
            if (this.puke13.alpha == 0.5) { var p = this.puke13.source + ""; var temp = p.split("_"); var inde = parseInt(temp[0]) - 1; kickcard = this.pai[inde]; }
            if (this.puke14.alpha == 0.5) { var p = this.puke14.source + ""; var temp = p.split("_"); var inde = parseInt(temp[0]) - 1; kickcard = this.pai[inde]; }
            this.tishi.visible = this.btntishi.visible = this.btntanpai.visible = false;
            this.soket.sendMessage(tool.SendData.sendKickCardData(kickcard));
        }
        private ShowTimerComFunc(event: egret.TimerEvent) {
            this.btntanpai.visible = this.tishi.visible = this.btntishi.visible = false;
            //所有牌不可见
            this.puke11.visible = this.puke12.visible = this.puke13.visible = this.puke14.visible = this.puke21.visible = this.puke22.visible = this.puke23.visible = this.puke24.visible = false
            this.puke31.visible = this.puke32.visible = this.puke33.visible = this.puke34.visible = this.puke41.visible = this.puke42.visible = this.puke43.visible = this.puke44.visible = false
            this.puke51.visible = this.puke52.visible = this.puke53.visible = this.puke54.visible = this.puke61.visible = this.puke62.visible = this.puke63.visible = this.puke64.visible = false
            //所有注数消失
            this.zhushu1.visible = this.zhushu2.visible = this.zhushu3.visible = this.zhushu4.visible = this.zhushu5.visible = this.zhushu6.visible = false
            //所有牌型图片消失
            this.paixing11.visible = this.paixing12.visible = this.paixing21.visible = this.paixing22.visible = this.paixing31.visible = this.paixing32.visible = this.paixing41.visible = false
            this.paixing42.visible = this.paixing51.visible = this.paixing52.visible = this.paixing61.visible = this.paixing62.visible = false

        }
        public id = [];
        private jiesuanjinbi(data) {
            this.puke11.alpha = this.puke12.alpha = this.puke13.alpha = this.puke14.alpha = 1;
            var ShowTimer: egret.Timer = new egret.Timer(1000, 3);//牌型显示倒计时
            ShowTimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.ShowTimerComFunc, this);
            ShowTimer.start();

            var JieSuanTimer: egret.Timer = new egret.Timer(1000, 5);//结算金币数字显示倒计时
            JieSuanTimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.JieSuanTimerComFunc, this);

            var item = data["score_board"];
            var jinbi = [];
            var m = PuKeMenager.four(GameViewPlay.user_accound, window.localStorage.getItem("account_id"));//本人所在index
            var other;
            for (var k = 0; k < GameViewPlay.user_accound.length; k++) {
                other = PuKeMenager.four(GameViewPlay.user_accound, GameViewPlay.user_accound[k]);//别人所在index
                if (other < m) {//将玩家ID按本机座位顺序排序
                    this.id[GameViewPlay.user_accound.length + other - m] = GameViewPlay.user_accound[k];
                } else {
                    this.id[other - m] = GameViewPlay.user_accound[k];
                }
            }
            for (var k = 0; k < this.id.length; k++) {
                for (var i in item) {
                    if (i == this.id[k]) {
                        jinbi[k] = item[i]; break;//将玩家金币数按本机座位排序
                    }
                }
            }
            var winner = [];
            var loser = [];
            //显示每个玩家的金币加减值
            if (jinbi[0] && jinbi[0] != parseInt(this.jinbi1.text)) {
                if (jinbi[0] - parseInt(this.jinbi1.text) > 0) { this.jiesuanjinbi1.text = "+" + (jinbi[0] - parseInt(this.jinbi1.text)) + ""; this.jiesuanjinbi1.textColor = 0xDDB554; winner.push([85, 1060]); }
                else { this.jiesuanjinbi1.text = jinbi[0] - parseInt(this.jinbi1.text) + ""; this.jiesuanjinbi1.textColor = 0xf9f9f7; loser.push([85, 1060]); }
                this.jiesuanjinbi1.visible = true; this.jinbi1.text = jinbi[0] + "";
            }
            if (jinbi[1] && jinbi[1] != parseInt(this.jinbi2.text)) {
                if (jinbi[1] - parseInt(this.jinbi2.text) > 0) { this.jiesuanjinbi2.text = "+" + (jinbi[1] - parseInt(this.jinbi2.text)) + ""; this.jiesuanjinbi2.textColor = 0xDDB554; winner.push([20, 735]); }
                else { this.jiesuanjinbi2.text = jinbi[1] - parseInt(this.jinbi2.text) + ""; this.jiesuanjinbi2.textColor = 0xf9f9f7; loser.push([20, 735]); }
                this.jiesuanjinbi2.visible = true; this.jinbi2.text = jinbi[1] + "";
            }
            if (jinbi[2] && jinbi[2] != parseInt(this.jinbi3.text)) {
                if (jinbi[2] - parseInt(this.jinbi3.text) > 0) { this.jiesuanjinbi3.text = "+" + (jinbi[2] - parseInt(this.jinbi3.text)) + ""; this.jiesuanjinbi3.textColor = 0xDDB554; winner.push([20, 525]); }
                else { this.jiesuanjinbi3.text = jinbi[2] - parseInt(this.jinbi3.text) + ""; this.jiesuanjinbi3.textColor = 0xf9f9f7; loser.push([20, 525]); }
                this.jiesuanjinbi3.visible = true; this.jinbi3.text = jinbi[2] + "";
            }
            if (jinbi[3] && jinbi[3] != parseInt(this.jinbi4.text)) {
                if (jinbi[3] - parseInt(this.jinbi4.text) > 0) { this.jiesuanjinbi4.text = "+" + (jinbi[3] - parseInt(this.jinbi4.text)) + ""; this.jiesuanjinbi4.textColor = 0xDDB554; winner.push([20, 290]); }
                else { this.jiesuanjinbi4.text = jinbi[3] - parseInt(this.jinbi4.text) + ""; this.jiesuanjinbi4.textColor = 0xf9f9f7; loser.push([20, 290]); }
                this.jiesuanjinbi4.visible = true; this.jinbi4.text = jinbi[3] + "";
            }
            if (jinbi[4] && jinbi[4] != parseInt(this.jinbi5.text)) {
                if (jinbi[4] - parseInt(this.jinbi5.text) > 0) { this.jiesuanjinbi5.text = "+" + (jinbi[4] - parseInt(this.jinbi5.text)) + ""; this.jiesuanjinbi5.textColor = 0xDDB554; winner.push([695, 525]); }
                else { this.jiesuanjinbi5.text = jinbi[4] - parseInt(this.jinbi5.text) + ""; this.jiesuanjinbi5.textColor = 0xf9f9f7; loser.push([695, 525]); }
                this.jiesuanjinbi5.visible = true; this.jinbi5.text = jinbi[4] + "";
            }
            if (jinbi[5] && jinbi[5] != parseInt(this.jinbi6.text)) {
                if (jinbi[5] - parseInt(this.jinbi6.text) > 0) { this.jiesuanjinbi6.text = "+" + (jinbi[5] - parseInt(this.jinbi6.text)) + ""; this.jiesuanjinbi6.textColor = 0xDDB554; winner.push([695, 735]); }
                else { this.jiesuanjinbi6.text = jinbi[5] - parseInt(this.jinbi6.text) + ""; this.jiesuanjinbi6.textColor = 0xf9f9f7; loser.push([695, 735]); }
                this.jiesuanjinbi6.visible = true; this.jinbi6.text = jinbi[5] + "";
            }
            for (var l = 0; l < loser.length; l++) {
                this.jinbi_play(loser[l][0], loser[l][1], winner[0][0], winner[0][1]);
            }
            var CoinTimer: egret.Timer = new egret.Timer(1000, 3);//结算金币数字显示倒计时
            CoinTimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.Coin, this);
            CoinTimer["winner"] = winner;
            JieSuanTimer.start();
        }
        private Coin(event: egret.TimerEvent = null) {//摊牌倒计时结束触发事件，选牌提示框消失,提示和摊牌按钮消失，所有牌型图片出现
            var ti = event.currentTarget as egret.Timer;
            var winner = ti["winner"];
            for (var l = 1; l < winner.length; l++) {
                this.jinbi_play(winner[0][0], winner[0][1], winner[l][0], winner[l][1]);
            }
        }
        private JieSuanTimerComFunc(event: egret.TimerEvent) {
            this.jiesuanjinbi1.visible = this.jiesuanjinbi2.visible = this.jiesuanjinbi3.visible = this.jiesuanjinbi4.visible = this.jiesuanjinbi5.visible = this.jiesuanjinbi6.visible = false;
            this.reset();
        }
        private jump_jiesuan() {//判断是否跳转到结算页面
            var str: string = this.jushu.text;
            var temp = str.split("/")
            if (temp.length > 1) {
                var str = temp[1]
                var index: number = str.indexOf("局")
                var endStr = str.substr(0, index);
                if (parseInt(temp[0]) > parseInt(endStr)) {//本局数等于所有局数时房间关闭去斗牛榜
                    var obj = {};
                    if (GameViewPlay.user_accound.length == 2) {
                        obj["name"] = [this.nicheng1.text, this.nicheng2.text];
                        obj["jinbi"] = [parseInt(this.jinbi1.text), parseInt(this.jinbi2.text)]
                    }
                    if (GameViewPlay.user_accound.length == 3) {
                        obj["name"] = [this.nicheng1.text, this.nicheng2.text, this.nicheng3.text];
                        obj["jinbi"] = [parseInt(this.jinbi1.text), parseInt(this.jinbi2.text), parseInt(this.jinbi3.text)]
                    }
                    if (GameViewPlay.user_accound.length == 4) {
                        obj["name"] = [this.nicheng1.text, this.nicheng2.text, this.nicheng3.text, this.nicheng4.text];
                        obj["jinbi"] = [parseInt(this.jinbi1.text), parseInt(this.jinbi2.text), parseInt(this.jinbi3.text), parseInt(this.jinbi4.text)]
                    }
                    if (GameViewPlay.user_accound.length == 5) {
                        obj["name"] = [this.nicheng1.text, this.nicheng2.text, this.nicheng3.text, this.nicheng4.text, this.nicheng5.text];
                        obj["jinbi"] = [parseInt(this.jinbi1.text), parseInt(this.jinbi2.text), parseInt(this.jinbi3.text), parseInt(this.jinbi4.text), parseInt(this.jinbi5.text)]
                    }
                    if (GameViewPlay.user_accound.length == 6) {
                        obj["name"] = [this.nicheng1.text, this.nicheng2.text, this.nicheng3.text, this.nicheng4.text, this.nicheng5.text, this.nicheng6.text];
                        obj["jinbi"] = [parseInt(this.jinbi1.text), parseInt(this.jinbi2.text), parseInt(this.jinbi3.text), parseInt(this.jinbi4.text), parseInt(this.jinbi5.text), parseInt(this.jinbi6.text)]
                    }
                    obj["id"] = this.id;
                    this.dispatchEventWith(GameViewPlay.Win, true, obj);
                }
            }
        }
        private reset() {//再来一局倒计时结束触发事件，选牌提示框消失
            this.deletcoins();
            this.jump_jiesuan();
            this.btnready.visible = true; this.btntanpai.enabled = false;
            this.textready1.visible = this.textready2.visible = this.textready3.visible = this.textready4.visible = this.textready5.visible = this.textready6.visible = false;
            this.timergroup.visible = this.xiazhu.visible = this.btntanpai.visible = this.btntishi.visible = this.tishi.visible = this.btnqiangzhuang.visible = this.btnbuqiang.visible = false;
            this.puke11.alpha = this.puke12.alpha = this.puke13.alpha = this.puke14.alpha = 1;
            this.paixing11.visible = this.paixing12.visible = this.paixing21.visible = this.paixing22.visible = this.paixing31.visible = this.paixing32.visible = this.paixing41.visible = this.paixing42.visible = this.paixing51.visible = this.paixing52.visible = this.paixing61.visible = this.paixing62.visible = false;
            this.puke11.source = "card_png"//所有牌背面朝上
            this.puke12.source = "card_png"
            this.puke13.source = "card_png"
            this.puke14.source = "card_png"
            this.puke21.source = "card_png"
            this.puke22.source = "card_png"
            this.puke23.source = "card_png"
            this.puke24.source = "card_png"
            this.puke31.source = "card_png"
            this.puke32.source = "card_png"
            this.puke33.source = "card_png"
            this.puke34.source = "card_png"
            this.puke41.source = "card_png"
            this.puke42.source = "card_png"
            this.puke43.source = "card_png"
            this.puke44.source = "card_png"
            this.puke51.source = "card_png"
            this.puke52.source = "card_png"
            this.puke53.source = "card_png"
            this.puke54.source = "card_png"
            this.puke61.source = "card_png"
            this.puke62.source = "card_png"
            this.puke63.source = "card_png"
            this.puke64.source = "card_png"

            this.puke11.x = 327; this.puke11.y = -485//所有牌位置复原
            this.puke12.x = 327; this.puke12.y = -485
            this.puke13.x = 327; this.puke13.y = -485
            this.puke14.x = 327; this.puke14.y = -485
            this.puke21.x = 345; this.puke21.y = -204
            this.puke22.x = 345; this.puke22.y = -204
            this.puke23.x = 345; this.puke23.y = -204
            this.puke24.x = 345; this.puke24.y = -204
            this.puke31.x = 345; this.puke31.y = 15
            this.puke32.x = 345; this.puke32.y = 15
            this.puke33.x = 345; this.puke33.y = 15
            this.puke34.x = 345; this.puke34.y = 15
            this.puke41.x = 344; this.puke41.y = 235
            this.puke42.x = 344; this.puke42.y = 235
            this.puke43.x = 344; this.puke43.y = 235
            this.puke44.x = 344; this.puke44.y = 235
            this.puke51.x = -172; this.puke51.y = 15
            this.puke52.x = -172; this.puke52.y = 15
            this.puke53.x = -172; this.puke53.y = 15
            this.puke54.x = -172; this.puke54.y = 15
            this.puke61.x = -172; this.puke61.y = -205
            this.puke62.x = -172; this.puke62.y = -205
            this.puke63.x = -172; this.puke63.y = -205
            this.puke64.x = -172; this.puke64.y = -205

            this.zhuang1.visible = false//所有庄家图标消失
            this.zhuang2.visible = false
            this.zhuang3.visible = false
            this.zhuang4.visible = false
            this.zhuang5.visible = false
            this.zhuang6.visible = false
            //庄家头像发光消失
            this.touxiang11.visible = this.touxiang22.visible = this.touxiang33.visible = this.touxiang44.visible = this.touxiang55.visible = this.touxiang66.visible = false;
        }
        public cards_weizhi(count: number) {
            var obj = RES.getRes("config_json");
            if (obj) {
                for (var i: number = 0; i < 4; i++) {
                    this[obj[count].name].x = obj[count]["data"]["x"];
                    this[obj[count].name].y = obj[count]["data"]["y"];
                    if (obj[count].name == "puke11" || obj[count].name == "puke12" || obj[count].name == "puke13" || obj[count].name == "puke14") {
                        this[obj[count].name].width = obj[count]["data"]["width"];
                        this[obj[count].name].height = obj[count]["data"]["height"];
                    }
                    count++;
                }
            }
        }
        public jinbi_play(x: number, y: number, to_x: number, to_y: number) {
            SoundMenager.Shared().PlayClick();
            var coin = new eui.Image;
            coin["name"] = "coin";
            coin.x = x;
            coin.y = y;
            coin.width = 40;
            coin.height = 40;
            coin.source = "bull_coin_png";
            this.addChild(coin);
            var obj = { "x": to_x, "y": to_y };
            var objValue = { "count": 1, "index": 0, "that": this, "data": obj, "it": { "x": x, "y": y } };
            this.jinbimove(coin, obj, objValue, 1);
        }
        private jinbimove(img: eui.Image, obj, objValue, count) {
            var ease: Function = egret.Ease.sineIn;
            if ((count - 1) == 4) {
                egret.Tween.get(img, { loop: false, onChangeObj: this }).to(obj, 600, ease).wait(900).call(this.deletcoins, this, []);
            } else {
                if (img && obj) {
                    egret.Tween.get(img, { loop: false, onChange: this.onJinbiChange, onChangeObj: objValue }).to(obj, 600, ease);
                }
            }
        }
        public deletcoins() {
            var coin = [];
            for (var item in this.$children) {
                if (this.$children[item]["name"] && this.$children[item]["name"] == "coin") {
                    coin.push(this.$children[item]);
                }
            }
            for (var i = 0; i < coin.length; i++) {
                this.removeChild(coin[i]);
            }
        }
        private onJinbiChange(e) {
            this['index'] = this['index'] + 1;
            var to_data = this["data"];//移动去的xy坐标
            var count = this["count"];
            var that = this["that"];
            var it = this["it"];
            if (count < 5) {//count为金币数，数目为5时即停止缓动
                if (this['index'] % 2 == 0) {//onChange函数调用次数是2的倍数就发下一张牌
                    if (it) {
                        var coin = new eui.Image;
                        coin["name"] = "coin";
                        coin.x = it["x"];
                        coin.y = it["y"];
                        coin.width = 40;
                        coin.height = 40;
                        coin.source = "bull_coin_png";
                        that.addChild(coin);
                        var temp = this["count"] + 1;;
                        this["count"] = temp;
                        that.jinbimove(coin, to_data, this, temp);
                    }
                }
            }
        }
        public static copy(message: string): void {
            var input = document.createElement("input");
            input.value = message;
            document.body.appendChild(input);
            input.select();
            input.setSelectionRange(0, input.value.length),document.execCommand('Copy');
            document.body.removeChild(input);
        }
    }
}